// 助战加点 {"助战编号":1,"加点":{"魔力":0,"耐力":0,"敏捷":0,"力量":0,"体质":4}}

// @ts-ignore
export async function execute(client_id,message_json) {
    let index = message_json["助战编号"];
    let characters = G.HelpFight.get_help_fight_characters(client_id, index-1);


    let sum = message_json["加点"]["魔力"] + message_json["加点"]["耐力"] + message_json["加点"]["敏捷"] + message_json["加点"]["力量"] + message_json["加点"]["体质"];

    if (sum <= 0) {
        //什么都不做
        ClientUtils.send_basic_prompt(client_id, "#Y没有提交任何加点信息");
        return;
    }
    if (characters["潜力"] < 1) {
        ClientUtils.send_basic_prompt(client_id, "#Y潜力值不足");
        return;
    }
    if (sum > characters["潜力"]) {
        ClientUtils.send_basic_prompt(client_id, "#Y潜力值不足");
        return;
    }

    characters["潜力"] = characters["潜力"] - sum;

    //更新加点方案
    characters["加点方案"][0]["潜力"] = characters["潜力"];
    characters["加点方案"][0]["体质"] += message_json["加点"]["体质"];
    characters["加点方案"][0]["魔力"] += message_json["加点"]["魔力"];
    characters["加点方案"][0]["力量"] += message_json["加点"]["力量"];
    characters["加点方案"][0]["耐力"] += message_json["加点"]["耐力"];
    characters["加点方案"][0]["敏捷"] += message_json["加点"]["敏捷"];

    //更新属性
    characters["体质"] += message_json["加点"]["体质"];
    characters["魔力"] += message_json["加点"]["魔力"];
    characters["力量"] += message_json["加点"]["力量"];
    characters["耐力"] += message_json["加点"]["耐力"];
    characters["敏捷"] += message_json["加点"]["敏捷"];

    //通知客户端更新助战面板加点信息
    G.Characters.computing_characters_data(characters)
    let send_data = Object.assign({}, characters);
    send_data["助战编号"] = index;
    ClientUtils.send_client_message(client_id, 2007, send_data);
}